import { defineStore } from 'pinia';
import { store } from '@/store/index';

export const useCodeStore = defineStore('code', {
  state: () => {
    return {
      curDragField: {}, // 当前拖拽的字段信息，根据此信息判断ghost样式
      isPageInfoRefresh: false // 判断页面管理的列表是否需要刷新
    };
  },
  getters: {
    getCurDragField(): any {
      return this.curDragField;
    },
    getIsPageInfoRefresh(): boolean {
      return this.isPageInfoRefresh;
    }
  },
  actions: {
    setCurDragField(curDragField: any) {
      this.curDragField = curDragField;
    },
    setIsPageInfoRefresh(isPageInfoRefresh: boolean) {
      this.isPageInfoRefresh = isPageInfoRefresh;
    }
  }
});

export const useCodeStoreWithOut = () => {
  return useCodeStore(store);
};
